﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="~/Content/bootstrap.min.css" rel="stylesheet" />
    <title>WechatPay</title>
</head>
<body>
    <div class="container-fluid" style="height:40px;background-color:#0ae;margin-bottom:15px;">
        <div class="row">
            <div class="col-xs-12" style="text-align:center;line-height:40px;color:white;">在线充值</div>
        </div>
    </div>

    <div class="container">
        <div class="ibox-content">
            <form id="payform" class="form-horizontal" method="post">
                <div class="form-group">
                    <label class="col-sm-3 control-label" style="font-size:18px;">充值金额：</label>
                    <div class="col-sm-8">
                        <input id="amount" name="amount" placeholder="充值金额" class="form-control" style="height:46px;">
                        <span class="help-block m-b-none" style="margin-bottom:0px;">最低充值金额为 <font style="color:red;">10.00 </font>元</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label" style="font-size:18px;">会员账号：</label>
                    <div class="col-sm-8">
                        <input id="username" name="username" placeholder="会员账号" class="form-control" style="height:46px;">
                        <span class="help-block" style="color:red;margin-top:10px;margin-bottom:5px;">*请先在平台提交入款订单，否则无法及时到帐！</span>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-12">
                        <button type="button" onclick="SubPay()" style="height:46px;" class="btn btn-block btn-primary">微信支付充值</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>
    <script src="~/Scripts/jquery.easyui.min.js"></script>
    <script src="~/js/plugins/layer/layer.min.js"></script>
</body>
</html>
<script>
    $(function () {
        
    })
    var layer_load;
    function SubPay() { 
        $('#payform').form('submit', {
            url: '/WechatPay/Pay',
            onSubmit: function () {
                var username = $('#username').val();
                var amount = $('#amount').val();
                if (amount.length == 0) {
                    layer.msg("请输入金额");
                    return false;
                }
                if (Number(amount) < 10) {
                    layer.msg("最低充值金额为 10 元");
                    return false;
                }
                if (isNaN(amount)) {
                    layer.msg("充值金额只能为数字");
                    return false;
                }
                if (!(/(^[1-9]\d*$)/.test(amount))) {
                    layer.msg('请输入正整数');
                    return false; 
                }
                var mu = /^\w{1,30}$/;
                if (username.length == 0) {
                    layer.msg("请输入会员账号");
                    return false;
                }
                if (!(mu.test(username))) {
                    layer.msg("会员帐号只能输入英文、数字及下划线");
                    return false;
                }
                layer_load = layer.load(0, { shade: false });
            },
            success: function (data) {
                layer.close(layer_load);
                console.log(data);
                data = eval('(' + data + ')');
                if (data.status == 0) {
                    layer.msg(data.msg, { icon: 1 });
                    $('#payform').form('clear');
                } else {
                    layer.msg(data.msg, { icon: 2 });
                }
            }
        });
    };
    //function SubPay() {
    //    windows.location.href = '/WechatPay/zhifu2';
    //}
</script>